package financial.sharing.center.common.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName DateUtil
 * @Description TODO
 * @Author guoyuhang
 * @ @csdn https://blog.csdn.net/qq_40788718
 * @Date 2021/4/27
 * @Version 1.0
 */
public class DateUtil {

    public static Date format(String date) {
        return format(date, null);
    }

    public static Date format(String date, String pattern) {
        if (pattern == null || pattern.equals("") || pattern.equals("null")) {
            pattern = "yyyy-MM-dd";
        }
        if (date == null || date.equals("") || date.equals("null")) {
            pattern = "mm:ss";
        }
        Date d = null;
        try {
            d = new SimpleDateFormat(pattern).parse(date);
        } catch (ParseException pe) {
            pe.printStackTrace();
        }
        return d;
    }
}
